package com.twu.biblioteca.view.console;

import com.google.common.collect.Maps;
import com.google.inject.Inject;
import com.google.inject.name.Named;

import com.twu.biblioteca.enums.MapKey;
import com.twu.biblioteca.enums.ViewState;

import java.util.Map;

public class ViewResolverMap {
  private Map<ViewState, ViewResolver> viewResolverMap = Maps.newHashMap();

  @Inject
  public void setWelcomeViewResolver(@Named("welcome") ViewResolver welcomeViewResolver) {
    viewResolverMap.put(ViewState.Welcome, welcomeViewResolver);
  }

  @Inject
  public void setBookListViewResolver(@Named("bookList")ViewResolver bookListViewResolver) {
    viewResolverMap.put(ViewState.BookList, bookListViewResolver);
  }

  @Inject
  public void setMenuViewResolver(@Named("menu") ViewResolver menuViewResolver) {
    viewResolverMap.put(ViewState.Menu, menuViewResolver);
  }

  @Inject
  public void setUserInfoViewResolver(@Named("userInfo") ViewResolver menuViewResolver) {
    viewResolverMap.put(ViewState.UserInfo, menuViewResolver);
  }

  @Inject
  public void setMovieListViewResolver(@Named("movieList") ViewResolver menuViewResolver) {
    viewResolverMap.put(ViewState.MovieList, menuViewResolver);
  }

  public String getMessageAtConsole(ViewState viewState, Map<MapKey, Object> model) {
    return viewResolverMap.get(viewState).getView(model);
  }
}
